<?php

namespace addons\config\model;

/**
 * Description of Help
 *
 * @author shilinqing
 */
class Help extends \web\common\model\BaseModel {
    
    protected function _initialize() {
        $this->tableName = 'sys_help';
    }
    public function getHelpList($pageIndex = -1, $pageSize = -1, $filter = '', $order = 'a.order_index desc') {
        $sql = 'select a.*,b.class_name from ' . $this->getTableName()  . ' AS  a LEFT JOIN tp_sys_help_class AS b ON a.class_id = b.id';
        if (!empty($filter)) {
            $sql = $sql . ' where ' . $filter;
        }
        return $this->getDataListBySQL($sql, $pageIndex, $pageSize, $order);
    }

    /**
     * 获取记录总数
     * @param type $filter
     * @return int
     */
    public function getHelpTotal($filter = '') {
        $sql = 'select count(*) as c from  ' . $this->getTableName()  . ' AS  a LEFT JOIN tp_sys_help_class AS b ON a.class_id = b.id';
        if (!empty($filter))
            $sql .= ' where ' . $filter;
        $result = $this->query($sql);

        if (count($result) > 0)
            return intval($result[0]['c']);
        else
            return 0;
    }
}